﻿using System;
using Auxiliary.VecMath;
using Simple3DRedactor.Domain;
using Tao.OpenGl;

namespace Simple3DRedactor.OpenGLViewer
{
    class CylinderView : GeometryView<Cylinder>
    {
        private readonly Glu.GLUquadric _quadric = Glu.gluNewQuadric();

        public CylinderView(Cylinder obj, ObjectViewFactory factory) : base(obj, factory)
        {
            Glu.gluQuadricTexture(_quadric, Gl.GL_TRUE);
        }

        protected override void RenderImpl()
        {
            Glu.gluCylinder(_quadric, InnerObject.BaseRadius, InnerObject.TopRadius, InnerObject.Height, InnerObject.Slices, InnerObject.Stacks);
        }

        protected override Vector3D MaxPoint
        {
            get { return new Vector3D(Math.Max(InnerObject.BaseRadius, InnerObject.TopRadius), Math.Max(InnerObject.BaseRadius, InnerObject.TopRadius), InnerObject.Height); }
        }

        protected override Vector3D MinPoint
        {
            get { return new Vector3D(-Math.Max(InnerObject.BaseRadius, InnerObject.TopRadius), -Math.Max(InnerObject.BaseRadius, InnerObject.TopRadius), 0.0f); }
        }
    }
}
